package com.king01.controller;

import com.king01.entity.Dept;
import com.king01.service.DeptService;
import com.king01.vo.DeptVo;
import com.king01.vo.Result;
import com.king01.vo.StaffVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;
/**
 @create by: George周
 * @description: 查询所有部门
 * @create time: 2023/10/10 15:30
  * @param
* @return */
    @RequestMapping("/list")
    public Result list(Integer currentPage1, Integer pageSize1){

        Result result = deptService.findAllDept(currentPage1, pageSize1);
        return result;

    }
    //添加
    @RequestMapping("/add")
    @ResponseBody
    public Result add(@RequestBody Dept dept){
        Result result = deptService.add(dept);
        return result;
    }
    @RequestMapping("/del")
    @ResponseBody
    public Result del(Integer deptid){
        Result result = deptService.del(deptid);
        return result;
    }

    @RequestMapping("/update1")
    @ResponseBody
    public Result update1(@RequestBody DeptVo deptVo){
        System.out.println("111111"+deptVo);
        Result result = deptService.update1(deptVo);
        return result;
    }
    @RequestMapping("/selByDeptId")
    public Result selByDeptId(Integer page, Integer pageSize,Integer deptid){

        Result result = deptService.selByDeptId(page,pageSize,deptid);
        System.out.println(result);
        return result;
    }
}

